package cn.op.portal.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

//该加密算法是单向加密，即加密的数据不能再通过解密还原。
public class Md5Utils {
	public static String doMd5(String ... args) {
		StringBuilder sb = new StringBuilder();
		for(String str:args) {
			sb.append(str);
		}
		
		try {
			MessageDigest md = MessageDigest.getInstance("md5");    
			byte[] md5 = md.digest(sb.toString().getBytes());
			
			BASE64Encoder encoder = new BASE64Encoder();
			return encoder.encode(md5);
		} catch (NoSuchAlgorithmException e) {
			//e.printStackTrace();
			throw new RuntimeException(e);
		}
	}
}
